﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System.Security.Principal;
using WebApiDemo.Entity;

namespace WebApiDemo.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        #region Identity
        private readonly ILogger<UserController> _logger;

        private IConfiguration _iConfiguration;

        public UserController(ILogger<UserController> logger, IConfiguration configuration)
        {
            _logger = logger;
            this._iConfiguration = configuration;
        }
        #endregion

        [HttpGet]
        [Authorize]//要求通过授权才行
        public User Get(int id)
        {
            //var u = this._iUserService.FindUser(id);
            return new User()
            {
                Id = id,
                Account = "admin" + "MA",
                Name = "Admin",
                Role = "Administrator",
                Email = "2043708045@qq.com",
                LoginTime = DateTime.Now,
                Password = "admin" + "K8S"
            };
        }

    }
}
